package com.bkgy.controller.acidplan.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bkgy.controller.acidplan.dao.AcidPlanDao;
import com.bkgy.controller.acidplan.entity.AcidPlan;
import com.bkgy.controller.acidplan.service.AcidPlanService;
import com.bkgy.controller.optimize.entity.AcidRollingProductRequest;
import com.bkgy.sys.common.entity.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;


/**
 * 酸扎计划仿真服务实现类
 */
@Service
public class AcidPlanServiceImpl implements AcidPlanService {
    @Autowired
    private AcidPlanDao acidPlanDao;

    @Override
    public ResultData getAcidPlanData(AcidRollingProductRequest request) {
        try {
            Page<?> page = new Page<>(request.getPageIndex(), request.getPageSize());
            List<AcidPlan> list = acidPlanDao.getAcidPlanData(page,request);
            for(int i=0;i<list.size();i++){
                list.get(i).setRollForce1(list.get(i).getRollForce1().multiply(new BigDecimal(10)));
                list.get(i).setRollForce2(list.get(i).getRollForce2().multiply(new BigDecimal(10)));
                list.get(i).setRollForce3(list.get(i).getRollForce3().multiply(new BigDecimal(10)));
                list.get(i).setRollForce4(list.get(i).getRollForce4().multiply(new BigDecimal(10)));
                list.get(i).setRollForce5(list.get(i).getRollForce5().multiply(new BigDecimal(10)));
            }
            Integer count = acidPlanDao.getAcidPlanDataCount(request);
            return ResultData.ResultDataSuccess(list, count);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultData.ResultDataFaultSelf("获取失败" + e.getMessage(), null);
        }
    }
}
